package windowFactoryPackage;

import javax.swing.*;
import java.awt.event.*;
import java.awt.*;

public class DeveloperWindow extends WindowGenerator {
	private JLabel [] developerLabelArray = new JLabel[5];
	static JLabel [] developerDataArray = new JLabel[5];
	static String [] developerData = {"__IP Name__", "__StreetNumber__ __StreetName__",
		"__City__ __State__ __Zip__", "__Phone Number__", "__WebAddress__"};
	private JLabel [] fillerArray = new JLabel[4];
	private JButton jbtViewPrograms;
	private JPanel centerPanel, eastPanel, labelPanel, dataPanel;
	Query q = new Query();
	
	public DeveloperWindow(){
		setLayout(new BorderLayout());
		this.addWindowFocusListener(new WindowFocusListener(){
			@Override
			public void windowGainedFocus(WindowEvent e) {
				setLocationRelativeTo(null);				
			}
			@Override
			public void windowLostFocus(WindowEvent e) {
				Toolkit tk = Toolkit.getDefaultToolkit();
				Dimension devDim = getSize();
				Dimension dim = tk.getScreenSize();
				setLocation(dim.width - devDim.width, 0);
			}			
		});
		System.out.println(getSize());
		centerPanel = new JPanel();
		centerPanel.setLayout(new BorderLayout());
		centerPanel.setBorder(BorderFactory.createEtchedBorder());		
		
		labelPanel = new JPanel();
		labelPanel.setLayout(new GridLayout(5, 0, 10, 10));
		developerLabelArray[0] = new JLabel("Name: ");
		developerLabelArray[1] = new JLabel("Address: ");
		developerLabelArray[2] = new JLabel("");
		developerLabelArray[3] = new JLabel("Contact Number: ");
		developerLabelArray[4] = new JLabel("URL: ");
		for(int i = 0; i<developerLabelArray.length; i++){
			if(i != 2) developerLabelArray[i].setBorder(BorderFactory.createEtchedBorder());		
			labelPanel.add(developerLabelArray[i]);
		}
		
		centerPanel.add(labelPanel, BorderLayout.WEST);
		
		dataPanel = new JPanel();
		dataPanel.setLayout(new GridLayout(5, 0, 10, 10));
		for(int i = 0; i<developerDataArray.length; i++){
			developerDataArray[i] = new JLabel(developerData[i]);
			developerDataArray[i].setBorder(BorderFactory.createEtchedBorder());	
			dataPanel.add(developerDataArray[i]);
		}
		
		centerPanel.add(dataPanel, BorderLayout.CENTER);
		
		add(centerPanel, BorderLayout.CENTER);
		
		eastPanel = new JPanel();
		eastPanel.setLayout(new GridLayout(5, 0, 10, 10));
		eastPanel.setBorder(BorderFactory.createEtchedBorder());	
		
		for(int i = 0; i<fillerArray.length; i++){
			fillerArray[i] = new JLabel("");
			eastPanel.add(fillerArray[i]); 
		}
		jbtViewPrograms = new JButton("View Programs");
		jbtViewPrograms.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e){
				q.devProgWinQuery();
				WindowGenerator.generateDeveloperProgramWindow();
			}
		});
		eastPanel.add(jbtViewPrograms);
		
		add(eastPanel, BorderLayout.EAST);
	}
}
